from django.db import models
from db.base_model import BaseModel

# Create your models here.


class OrderInfo(BaseModel):
    '''订单模型'''
    ORDER_STATUS = (
        (0, '未支付'),(1,'已支付'),(2,'未运输'),(3,'运输中'),(4,'交易完成'),(5,'关闭交易')
    )
    PAY_METHON = (
        (0, '线上支付'), (1, '线下支付')
    )
    ONLINE_PAY_METHOD = (
        (0,'银联支付'),(1,'微信支付'),(2,'支付宝')
    )
    oder_id = models.CharField(max_length=50,verbose_name='订单号',primary_key=True)
    user = models.ForeignKey('user.UserInfo',verbose_name='所属用户')
    address = models.ForeignKey('user.UserAddress',verbose_name='收货地址')
    price = models.DecimalField(max_digits=10,decimal_places=2,verbose_name='售价')
    service_charge = models.DecimalField(max_digits=10,decimal_places=2,verbose_name='手续费')
    freight = models.DecimalField(max_digits=10,decimal_places=2,verbose_name='运费')
    stutus = models.IntegerField(choices=ORDER_STATUS,default=0,verbose_name='订单状态')
    pay_methon = models.IntegerField(choices=PAY_METHON,default=0,verbose_name='支付方式')
    online_pay_method = models.IntegerField(choices=ONLINE_PAY_METHOD,default=0,verbose_name='线上交易')


    def __str__(self):
        return str(self.oder_id)
    class Meta:
        verbose_name = '订单信息'
        verbose_name_plural = verbose_name

class OrderCar(BaseModel):
    '''订单车辆'''
    oder = models.ForeignKey('OrderInfo',verbose_name='订单')
    car_id = models.ForeignKey('secondcar.CarDetail',verbose_name='二手车编码')
    comment = models.CharField(max_length=1000,verbose_name='评论')

    class Meta:
        verbose_name = '订单车辆'
        verbose_name_plural = verbose_name